package c.f.b.a.a.a.a;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.Context;
import android.content.Intent;
import android.view.KeyEvent;
import android.view.Window;
import com.huawei.hms.game.f;
import com.huawei.hms.game.j;
import java.lang.ref.WeakReference;

public class a implements b {
    public WeakReference<Activity> a;
    public AlertDialog b = null;

    public final Activity a() {
        WeakReference weakReference = this.a;
        return weakReference == null ? null : (Activity) weakReference.get();
    }

    public void onBridgeActivityCreate(Activity activity) {
        this.a = new WeakReference(activity);
        AlertDialog a = c.f.a.a.a.a.a(activity, activity.getIntent() != null ? (com.huawei.hms.game.a) activity.getIntent().getParcelableExtra("appInfo") : null, j.b().a((Context) activity));
        this.b = a;
        a.show();
        Window window = this.b.getWindow();
        if (window != null) {
            f.a().a(window.getAttributes());
        }
    }

    public void onBridgeActivityDestroy() {
        this.a = null;
    }

    public boolean onBridgeActivityResult(int i, int i2, Intent intent) {
        Activity a = a();
        if (a == null) {
            return true;
        }
        a.finish();
        return true;
    }

    public void onBridgeConfigurationChanged() {
        AlertDialog alertDialog = this.b;
        if (alertDialog != null) {
            alertDialog.dismiss();
            if (a() != null) {
                Intent intent = a().getIntent();
                com.huawei.hms.game.a aVar = null;
                if (intent != null) {
                    aVar = (com.huawei.hms.game.a) intent.getParcelableExtra("appInfo");
                }
                alertDialog = c.f.a.a.a.a.a(a(), aVar, j.b().a(a()));
                this.b = alertDialog;
                alertDialog.show();
            }
        }
    }

    public void onKeyUp(int i, KeyEvent keyEvent) {
    }
}
